<?php
class M_bengkel extends CI_Model{
 
    function __construct()
    {
        parent::__construct();
    }
    
    function input_bengkel()
    {
        $now = date('Y-m-d');
        $simpan_data =  array(
                        'Judul'     => $this->input->post('judul'),
                        'Deskripsi' => $this->input->post('deskripsi'),
                        'Tanggal'   => $now,
                        'Kota'      => $this->input->post('kota'),
                        'Alamat'    => $this->input->post('alamat'),
                        'Telepon'   => $this->input->post('telepon')
                        );
        $simpan = $this->db->insert('bengkel_post', $simpan_data);
        return $simpan;
    }
    
    function get_id_bengkel($id)
    {
        $params = $this->db->get_where('bengkel_post', array('ID_Post'=>$id));
        return $params->row();
    }
    
    function edit_bengkel($id)
    {
        $id = $this->input->post('idbengkel');
        $edit_data  = array(
                      'Judul'     => $this->input->post('judul'),
                      'Deskripsi' => $this->input->post('deskripsi'),
                      'Kota'      => $this->input->post('kota'),
                      'Alamat'    => $this->input->post('alamat'),
                      'Telepon'   => $this->input->post('telepon')
                      );
        $this->db->where('ID_Post',$id);
        $this->db->update('bengkel_post',$edit_data);        
    }
    
    function get_bengkel()
    {
        $params = $this->db->get('bengkel_post');
        return $params->result();
    }
}